# import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By as by
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.action_chains import ActionChains as mouse
import time
import re

s = Service(r"/Users/didi1/Desktop/chromedriver.exe")
web = webdriver.Chrome(service=s)
web.implicitly_wait(10)
web.get("https://didifarm.intra.xiaojukeji.com/account/accountIntegrate/?t=apply&SSO_AS_SUB_FARM_TICKET=d16b0c911a070d84bd4de4444dd0c3f10001148000&js_sdk_sid=74546708-4f19-c4a5-60a5-e09998ab5a82")
web.maximize_window()
web.switch_to.frame(web.find_element(by.XPATH, '//*[@id="main"]'))
time.sleep(7)
web.find_element(by.XPATH, '//*[@id="div-account"]').send_keys("gongqinglu_v")
time.sleep(2)
web.find_element(by.XPATH, '//*[@id="password"]').send_keys("wUJI520.")
time.sleep(1)
web.find_element(by.XPATH, '//*[@id="submit"]').click()



# # 打开活动页面
# if web.find_element(by.XPATH, "//*[@id='main']/div[2]/div[1]/div/div[2]/div/div/div[1]/div"):
#     web.get_screenshot_as_file(r'/Users/didi1/Desktop/宫庆禄滴滴/ui自动化/弹窗截图.png')
#     print("领券弹窗截图成功")
# time.sleep(3)
# web.find_element(by.XPATH, "//*[@id='main']/div[2]/div[1]/div/div[2]/div/div/div[2]").click()
#
# # 鼠标从第一关拖动游戏到最后一关
# source = web.find_element(by.XPATH,
#                           "//*[@id='main']/div[1]/div[2]/div/div[1]/div[3]/div[3]/div[1]/div/div[1]/div/img")
# target = web.find_element(by.XPATH,
#                           "//*[@id='main']/div[1]/div[2]/div/div[1]/div[3]/div[3]/div[1]/div/div[3]/div/img")
# action = mouse(web)
# action.drag_and_drop(source, target).perform()
# time.sleep(1)
# web.get_screenshot_as_file(r'/Users/didi1/Desktop/宫庆禄滴滴/ui自动化/游戏最后一关截图.png')
# print("游戏最后一关截图成功")
# target.click()
# l = web.find_element(by.XPATH, '/html/body/div[2]').text
# print(l)
# # assert(l == "还未解锁喔～")
# time.sleep(5)
# web.close()
# # 点击开始游戏
# # btn=web.find_element(by.XPATH,'//*[@id="main"]/div[1]/div[2]/div/div[1]/div[3]/div[4]/img')
# # action.move_to_element(btn).click()
#
#
#

